<?php
namespace Home\Controller;
use Think\Controller;
header('content-type:text/html;charset="UTF-8"');
class IndexController extends Controller {
    public function index(){
    	$db=M('column');
    	$class1=$db->where("fid=0")->select();
    	
    	foreach ($class1 as $a => $val) {
    		$calss2 = array();
     		$class2=$db->where("fid={$val['id']}")->select();
     		
     		foreach ($class2 as $b => $value) {
     			$class3 = array( );
     			$class3=$db->where("fid={$value['id']}")->select();
     			$class2[$b]['class3']=$class3;
     		}
     		$class1[$a]['class2']=$class2;

    	}
    	$this->assign('class1',$class1);
        $dc=M('shopcart');//统计购物车的数量
        $uid=$_SESSION['uid'];
        if (!empty($uid)) {
            $dataCount=$dc->where("uid={$uid}")->select();
            $count=count($dataCount);
            $this->assign('count',$count);  
        }
        $this->display();
    }
    public function out(){
    	$_SESSION['uname']=null;
    	$_SESSION['uid']=null;
    	$this->redirect('Home/Index/index');
    }
}